<template>
  <div class="map-top-box">
    <div class="floor-box">
      <div>
        <!-- <div class="floor-item">1</div> -->
      </div>
    </div>
    <div class="map-info-content">
      <div class="title">
        <div class="left">
          <div class="point">
            <point-err></point-err>
            <span class="device-tip">预警</span>
            <span class="device-num"> {{warningNum}}</span>
          </div>
          <div class="point">
            <point-no-err></point-no-err>
            <span class="device-tip">无预警</span>
            <span class="device-num"> {{deviceNum}}</span>
          </div>
          <!--<div class="point">
            <point-offline></point-offline>
            <span>离线</span>
          </div>-->
        </div>
        <div class="right">
          <div class="flex">
            <img src="@/assets/images/warnView/device/online.png" />
            <span class="device-tip">在线设备</span>
            <span class="device-num">{{onlineNum}}</span>
          </div>
          <div class="flex">
            <img src="@/assets/images/warnView/device/offline.png" />
            <span class="device-tip">离线设备</span>
            <span class="device-num">{{offlineNum}}</span>
          </div>
        </div>
      </div>
      <hospital :allDeviceData="allDeviceData"
                :deviceId="deviceId"
                @warningNumFun="warningNumFun"
                @deviceNumFun="deviceNumFun"
                @selectLocationIdFun="selectLocationIdFun"></hospital>
    </div>
  </div>
</template>
<script>
import pointErr from "./components/pointErr";
import pointNoErr from "./components/pointNoErr";
import pointOffline from "./components/pointOffline";
import hospital from "./components/hospital";
import { getStatus } from "@/api/platformManage";
export default {
  components: {
    hospital,
    pointErr,
    pointOffline,
    pointNoErr
  },
  name: "MapInfo",
  props: {
    msg: String,
    deviceId: String,
    allDeviceData: Array,
    platformId: String
  },

  watch: {
    platformId(val) {
      getStatus(val).then(res => {
        let data = res.value;
        this.onlineNum = data.online;
        this.offlineNum = data.offline;
      });
    },
    allDeviceData(data) {
      this.warningNum = data.filter(e => {        if (e.alert && e.state == "ONLINE") {
          return e;
        }      }).length;
      this.deviceNum = data.filter(e => {        if (!e.alert && e.state == "ONLINE") {
          return e;
        }      }).length;

    },
  },
  mounted() {

  },
  data() {
    return {
      list: ["", "", "", ""],
      warningNum: 0,
      deviceNum: 0,
      current: {},
      onlineNum: 0,
      offlineNum: 0
    };
  },
  methods: {
    warningNumFun(number) {
      this.warningNum = number;
    },
    deviceNumFun(number) {
      this.deviceNum = number;
    },
    selectLocationIdFun(item) {
      this.$emit("selectLocationIdFun", item);
    }
  }
};
</script>
<style scoped lang="scss">
.map-top-box {
  border-radius: 12px;
  background-color: #fff;
  padding: 20px;
  height: 666px;
  display: flex;
  justify-content: flex-start;
  .floor-box {
    width: 40px;
    padding-right: 10px;
    .floor-item {
      width: 32px;
      background: rgba(224, 226, 228, 0.39);
      border-radius: 0px 12px 12px 0px;
      text-align: center;
      color: #fff;
    }
    .active {
      background-color: #393b3f;
    }
  }
  .map-info-content {
    flex: 1;
    .title {
      display: flex;
      justify-content: space-between;
      font-size: 14px;
      font-weight: 400;
      line-height: 19px;
      color: #292929;
      .left {
        .point {
          font-size: 16px;
          font-weight: 600;
          line-height: 27px;
          margin-right: 20px;
          :first-child {
            margin-right: 5px;
          }
          display: flex;
          align-items: center;
        }
        display: flex;
        justify-content: flex-start;
      }
      .device-tip {
        font-size: 16px;
        font-weight: 600;
        line-height: 27px;
        color: #0a0a0a;
        margin-right: 5px;
      }
      .device-num {
        font-size: 20px;
        font-weight: 600;
        line-height: 27px;
        color: #0a0a0a;
      }
      .right {
        display: flex;
        justify-content: flex-end;
        align-items: center;
        > :first-child {
          margin-right: 30px;
        }
        .flex {
          display: flex;
          align-items: center;
          img {
            margin-right: 10px;
            width: 25px;
          }
          .device-tip {
            font-size: 16px;
            font-weight: 600;
            line-height: 27px;
            color: #0a0a0a;
            margin-right: 5px;
          }
          .device-num {
            font-size: 20px;
            font-weight: 600;
            line-height: 27px;
            color: #0a0a0a;
          }
        }
      }
    }
  }
}
</style>
